package middleware

import (
	"fmt"
	"github.com/kataras/iris/v12"
	"time"
)

//统计执行时间的中间件
func StartTime(ctx iris.Context) {
	t1 := time.Now() // get current time
	ctx.Values().Set("start_time", t1)
	fmt.Println("开始时间:",t1)
	ctx.Next()

}

func EndTime(ctx iris.Context) {
	t1 := ctx.Values().Get("start_time")
	elapsed := time.Since(t1.(time.Time))
	fmt.Println(elapsed)
	ctx.Next()

}
